package com.virtual.repository.plugins.api;

import java.net.UnknownHostException;
import java.util.Collection;

import com.virtual.repository.common.queries.Query;
import com.virtual.repository.common.queries.ResultEntity;

/**
 * A common interface for database drivers. 
 * @author Zielony
 * @version 1.0
 */
public interface IDatabasePlugin {
	/**
	 * Connects to the database with available credentials.
	 * @throws UnknownHostException if the URL of the database server is not bound.
	 */
	public void connect() throws UnknownHostException;
	
	/**
	 * Disconnects the database.
	 */
	public void disconnect();
	
	/**
	 * Executes the query asking for possible multiple results.
	 * @param query the <code>Query</code> to be executed.
	 * @return a <code>Collection</code> of requested objects.
	 */
	public Collection<ResultEntity> executeQuery(Query query);
	
	/**
	 * Executes query asking for a single result only.
	 * @param query the <code>Query</code> to be executed.
	 * @return the single result matching the query.
	 */
	public ResultEntity executeQueryForSingleResult(Query query);
	
	/**
	 * Executes query asking for the count of matching results.
	 * @param query the <code>Query</code> to be executed.
	 * @return the number of the results matching the <code>query</code>.
	 */
	public long executeQueryForCount(Query query);
}